package com.qzsoft.zhjd.server.modules.laboratory.controller;

import com.qzsoft.zhjd.server.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;

import com.qzsoft.zhjd.server.modules.laboratory.service.CollectLaboratoryLudongService;
import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName LaboratoryLudongController
 * @Description 鲁东试验数据
 * @author linhuawei
 * @since 2022-04-18
 */
@Slf4j
@RestController
@RequestMapping("/datacollect/laboratory/ludong")
public class CollectLaboratoryLudongController {

    @Autowired
    private CollectLaboratoryLudongService collectLaboratoryLudongService;

    /**
     * @Title saveLudong
     * @Description 保存试验数据
     * @param DATA 传递参数
     * @return CODE 0：成功 1：失败 2：数据重复
     */
    @PostMapping
    public R receive(@RequestBody JSONObject json) {
        // 返回结果
        log.info("试验数据:{}", json);

        // 判断参数是否存在
        if (null == json) {
            return R.error("DATA_IS_NULL");
        }

        // 执行添加操作
        collectLaboratoryLudongService.receive(json);
        return R.ok();
    }

}
